//
//  AnimansTableViewCell.m
//  UIA段项目 墨家天气
//
//  Created by dllo on 15/9/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "AnimansTableViewCell.h"

@implementation AnimansTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
-(void)dealloc
{
    [_viewA release];
    [_high release];
    [_low release];
    [_highDu release];
    [_lowDu release];
    [_weather release];
    [_date release];
    [_gang release];
    [super dealloc];
    
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.viewA = [[UIView alloc]init];
        [self.contentView addSubview:_viewA];
        [self DrawLineWithView:_viewA];
        [_viewA release];
        
        self.weak = [[UILabel alloc]init];
        _weak.textColor = [UIColor whiteColor];
        _weak.font = [UIFont boldSystemFontOfSize:13 * OffWidth];
        [self.contentView addSubview:_weak];
        [_weak release];
        
        self.high = [[UILabel alloc]init];
        self.high.font = [UIFont systemFontOfSize:17 * OffWidth];

        _high.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_high];
        [_high release];
        
        self.low = [[UILabel alloc]init];
        self.low.font = [UIFont systemFontOfSize:17 * OffWidth];
        self.low.textColor = [UIColor whiteColor];
        
        [self.contentView addSubview:_low];
        [_low release];
        
        self.weather = [[UILabel alloc]init];
        _weather.textColor = [UIColor whiteColor];
        self.weather.font = [UIFont systemFontOfSize:15 * OffWidth];
        [self.contentView addSubview:_weather];
        [_weather release];
        
        self.date = [[UILabel alloc]init];
        _date.textColor = [UIColor grayColor];
        self.date.font = [UIFont boldSystemFontOfSize:13 * OffWidth];
        [self.contentView addSubview:_date];
        [_date release];
        
        
        
        self.gang = [[UILabel alloc]init];
        _gang.text = @"~";
        _gang.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_gang];
        [_gang release];

        
        self.highDu = [[UILabel alloc]init];
        self.highDu.text = @"。";
        self.highDu.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_highDu];
        [_highDu release];
        
        self.lowDu = [[UILabel alloc]init];
        self.lowDu.text = @"。";
        self.lowDu.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_lowDu];
        [_lowDu release];
        
   
   
    }
    
    return self;
    
}
-(void)layoutSubviews
{
    self.viewA.frame = CGRectMake(0, self.contentView.frame.size.height - 5 * OffWidth, self.contentView.frame.size.width, 5 * OffHeight);
    self.weak.frame = CGRectMake(10 * OffWidth, 10 * OffHeight, 50 * OffWidth, 20 * OffHeight);
    self.high.frame =  CGRectMake(self.contentView.frame.size.width - 80 * OffWidth, 10 * OffHeight, 50 * OffWidth, 50 * OffHeight);
    self.low.frame =  CGRectMake(self.contentView.frame.size.width - 40 * OffWidth, 10 * OffHeight, 50 * OffWidth, 50 * OffHeight);
    self.weather.frame = CGRectMake(self.contentView.frame.size.width - 200 * OffWidth, 10 * OffHeight, 80 * OffWidth, 50 * OffHeight);
    self.date.frame =  CGRectMake(10 * OffWidth, 20 * OffHeight, 200 * OffWidth, 40 * OffHeight);
    self.gang.frame = CGRectMake(self.contentView.frame.size.width - 57 * OffWidth, 25 * OffHeight, 20 * OffWidth, 20 * OffHeight);
    self.highDu.frame = CGRectMake(self.contentView.frame.size.width - 63 * OffWidth, 2 * OffHeight, 50 * OffWidth, 50 * OffHeight);
    self.lowDu.frame = CGRectMake(self.contentView.frame.size.width - 22 * OffWidth, 2 * OffHeight, 50 * OffWidth, 50 * OffHeight);
    
    

}
- (void)DrawLineWithView:(UIView *)view
{
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setBounds:view.bounds];
    [shapeLayer setPosition:view.center];
    [shapeLayer setFillColor:[[UIColor clearColor] CGColor]];
    
    // 设置虚线颜色为blackColor
    [shapeLayer setStrokeColor:[[UIColor whiteColor] CGColor]];
    //    [shapeLayer setStrokeColor:[[UIColor colorWithRed:223/255.0 green:223/255.0 blue:223/255.0 alpha:1.0f] CGColor]];
    
    // 3.0f设置虚线的宽度
    [shapeLayer setLineWidth:1.0f];
    [shapeLayer setLineJoin:kCALineJoinMiter];
    
    // 3=线的宽度 1=每条线的间距
    [shapeLayer setLineDashPattern:
     [NSArray arrayWithObjects:[NSNumber numberWithInt:3],
      [NSNumber numberWithInt:2],nil]];
    
    // Setup the path
    CGMutablePathRef path = CGPathCreateMutable();
    //    for (int i = 0; i < 6; i ++) {
    CGPathMoveToPoint(path, NULL, 0, 1);
    CGPathAddLineToPoint(path, NULL, 375 * OffWidth ,1);

    [shapeLayer setPath:path];
    CGPathRelease(path);
    
    // 可以把self改成任何你想要的UIView, 下图演示就是放到UITableViewCell中的
    [[self.contentView layer] addSublayer:shapeLayer];
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
